package org.wishwork.api.order;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wishwork.api.order.action.OrderActionQueryApi;
import org.wishwork.api.order.action.OrderActionQueryRequest;
import org.wishwork.api.order.action.OrderActionQueryResponse;
import org.wishwork.api.order.cancel.OrderCancelApi;
import org.wishwork.api.order.cancel.OrderCancelRequest;
import org.wishwork.api.order.cancel.OrderCancelResponse;
import org.wishwork.api.order.query.OrderQueryApi;
import org.wishwork.api.order.query.OrderQueryRequest;
import org.wishwork.api.order.query.response.OrderQueryResponse;
import org.wishwork.api.order.sent.OrderSentApi;
import org.wishwork.api.order.sent.OrderSentRequest;
import org.wishwork.api.order.sent.OrderSentResponse;
import org.wishwork.api.order.upload.OrderUploadApi;
import org.wishwork.api.order.upload.OrderUploadResponse;
import org.wishwork.api.order.upload.request.OrderUploadRequest;
import org.wishwork.context.Context;

import java.util.List;

/**
 * @description: 订单API
 * @author: WangYX
 * @create: 2022-04-13 10:24
 * @Version: 1.0.0
 **/

public class OrderApi {

    private static final Logger log = LoggerFactory.getLogger(OrderApi.class);

    private Context context;

    private final OrderQueryApi orderQueryApi;

    private final OrderSentApi orderSentApi;

    private final OrderCancelApi orderCancelApi;

    private final OrderActionQueryApi orderActionQueryApi;

    private final OrderUploadApi orderUploadApi;

    public OrderApi(Context context) {
        this.context = context;
        this.orderQueryApi = new OrderQueryApi(context);
        this.orderSentApi = new OrderSentApi(context);
        this.orderCancelApi = new OrderCancelApi(context);
        this.orderActionQueryApi = new OrderActionQueryApi(context);
        this.orderUploadApi = new OrderUploadApi(context);
    }

    /**
     * 订单查询
     *
     * @param orderQueryRequest
     * @return
     * @throws Exception
     */
    public List<OrderQueryResponse> query(OrderQueryRequest orderQueryRequest) throws Exception {
        return this.orderQueryApi.business(orderQueryRequest);
    }

    /**
     * 订单查询
     *
     * @param orderSentRequests
     * @return
     * @throws Exception
     */
    public OrderSentResponse sent(List<OrderSentRequest> orderSentRequests) throws Exception {
        return this.orderSentApi.business(orderSentRequests);
    }

    /**
     * 订单取消-按内部单号取消
     *
     * @param orderCancelRequest
     * @return
     * @throws Exception
     */
    public OrderCancelResponse cancel(OrderCancelRequest orderCancelRequest) throws Exception {
        return this.orderCancelApi.business(orderCancelRequest);
    }

    /**
     * 订单操作日志查询
     *
     * @param orderActionQueryRequest
     * @return
     * @throws Exception
     */
    public List<OrderActionQueryResponse> action(OrderActionQueryRequest orderActionQueryRequest) throws Exception {
        return this.orderActionQueryApi.business(orderActionQueryRequest);
    }

    /**
     * 订单上传(推荐)
     *
     * @param orderUploadRequests
     * @return
     * @throws Exception
     */
    public List<OrderUploadResponse> upload(List<OrderUploadRequest> orderUploadRequests) throws Exception {
        return this.orderUploadApi.business(orderUploadRequests);
    }

}
